class Probability:
	def normalize(self):
		total = 0
		total += self.open
		total += self.offTopic
		total += self.notConstructive
		total += self.notARealQuestion
		total += self.tooLocalized
		self.open = self.open/float(total)
		self.offTopic = self.offTopic/float(total)
		self.notConstructive = self.notConstructive/float(total)
		self.notARealQuestion = self.notARealQuestion/float(total)
		self.tooLocalized = self.tooLocalized/float(total)
	
	def cap(self, epsilon):
		if(self.open>1-epsilon):
			self.open = 1-epsilon
		if(self.open<epsilon):
			self.open = epsilon
		
		if(self.offTopic>1-epsilon):
			self.offTopic = 1-epsilon
		if(self.offTopic<epsilon):
			self.offTopic = epsilon
			
		if(self.notConstructive>1-epsilon):
			self.notConstructive = 1-epsilon
		if(self.notConstructive<epsilon):
			self.notConstructive = epsilon
		
		if(self.notARealQuestion>1-epsilon):
			self.notARealQuestion = 1-epsilon
		if(self.notARealQuestion<epsilon):
			self.notARealQuestion = epsilon
		
		if(self.tooLocalized>1-epsilon):
			self.tooLocalized = 1-epsilon
		if(self.tooLocalized<epsilon):
			self.tooLocalized = epsilon
		
		self.normalize()
		
	def __init__(self, id, status, open, offTopic, notConstructive, notARealQuestion, tooLocalized):
		self.id = id
		self.status = status 
		self.open = open
		self.offTopic = offTopic
		self.notConstructive = notConstructive
		self.notARealQuestion = notARealQuestion
		self.tooLocalized = tooLocalized
	
	def toLine(self):
		return str(self.id)+","+str(self.notARealQuestion)+","+str(self.notConstructive)+","+str(self.offTopic)+","+str(self.open)+","+str(self.tooLocalized)+"\n"